package com.epam.restexample.client;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import com.epam.restexample.entity.Customer;

public class ClientRunner {
	public static void main(String[] args){
		Client client = ClientBuilder.newClient();
		WebTarget target = client.target("http://localhost:8080/rest/customers");
		Customer customer = new Customer();
		customer.setFirstName("Dmitry");
		customer.setLastName("Pauliukevich");
		customer.setCountry("Belarus");
		customer.setCity("Minsk");
		customer.setState("Minsk");
		customer.setStreet("Dzerzhinskogo");
		customer.setZip("223610");
		Response resp = target.request(MediaType.APPLICATION_XML).put(Entity.xml(customer));
		int status = resp.getStatus();
		System.out.println(status);
		System.out.println(resp.getLocation());
		System.out.println("GET" + target.path("27").request(MediaType.APPLICATION_XML).get(Customer.class).getFirstName());
	}
}
